go/callgraph/rta: memoize method lookups in addInvokeEdge - #675
Open
hungcs wants to merge 1 commit into
Open
Conversation
addInvokeEdge runs for every (invoke site, runtime type) pair in the dynamic-dispatch matrix, and many sites share the same interface method and concrete type, so LookupMethod repeats the same method-set search — rebuilding method Id strings and comparing them — for each one. Cache the result per (interface method object, concrete type); both keys are pointer-identical across calls, so a hit is a single map lookup with no strings and no type hashing. Memory is bounded by the number of distinct pairs, a small fraction of call volume. On a 1,132-package monorepo, whole-program deadcode analysis drops from 210s to 156s wall (CPU 322s to 234s), with identical findings. Combined with CL 826224 and the MethodValue fast path, analysis is now faster than x/tools v0.45.0 was before generic-method support (186s on the same hardware against a smaller Go 1.26 tree). Updates golang/go#81308
Contributor
|
This PR (HEAD: 9887c22) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/827504. Important tips:
|
Contributor
|
Message from Hung-wei Chuang: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/827504. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second follow-up to golang/go#81308.
addInvokeEdge runs for every (invoke site, runtime type) pair in the
dynamic dispatch matrix. Many sites share the same interface method and
concrete type, so LookupMethod repeats the same method set search,
rebuilding method Id strings and comparing them, once per site.
This CL caches the result per (interface method object, concrete type).
Both keys are pointer-identical across calls, so a hit is a single map
lookup with no string building and no type hashing.
Makes deadcode ~25% faster on a benchmark of kubernetes/cmd/kubelet on
top of #674 (6.55s to 4.93s)
Updates golang/go#81308